#include<bits/stdc++.h>
#define sd(n) scanf("%d",&n) 
#define sld(n) scanf("%lld",&n)
#define pd(n) printf("%d", (n))
#define pld(n) printf("%lld", n)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define fi first
#define se second
const int N=2e5;
const int maxn=1e6;
typedef long long int ll;
using namespace std;
//----------------------------------------------------------------------------//

void solve()
{
	string s;
	char c;
	cin>>s>>c;
	int pos[110];
	int pos2=0;
	for(int i=0;i<s.size();i++)
	{
		if(s[i]==c)
		{
			pos[pos2]=(i+1);
			pos2++;
		}
	}
	int flag=0;
	for(int i=0;i<pos2;i++)
	{
		if((pos[i]-1)%2!=0)
		{
			continue;
		}
		if((s.size()-pos[i])!=0&&(s.size()-pos[i])%2!=0)
		{
			continue;
		}
		flag=1;
		cout<<"YES"<<'\n';
		return;

	}
	if(flag!=1)
	{
		cout<<"NO"<<'\n';
		return;
	}
	
}

int main()
{
	int T;
	sd(T);
	while (T--)
	{
		solve();
	}
	return 0;
}